﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YouWei.Infrastructure.Entity;
using YouWei.Infrastructure.Models;
using YouWei.Infrastructure.Service;

namespace YouWei.Op.Controllers
{
    public class CompanyController : BaseController
    {
        private CompanyService _service = new CompanyService();
        private UserInfoService _serviceUser = new UserInfoService();
        // GET: Company
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public PartialViewResult ParList(CompanySearchModel model)
        {

            var pageIndex = Convert.ToInt32(GetParam("page"));
            var pageSize = GetPageSize();
            var page = _service.Pages(pageIndex, pageSize, model);
            ViewBag.Total = page.total;
            ViewBag.PageIndex = pageIndex;
            ViewBag.PageSize = pageSize;
            return PartialView(page.rows);

        }
        public ActionResult CompanyInfo()
        {
            var id = Convert.ToInt32(GetParam("id"));
            var model = _service.Single(id);
            ViewBag.ID = id;
            return View(model);
        }
        public PartialViewResult ParUserList(UserSearchModel model)
        {
            var pageIndex = Convert.ToInt32(GetParam("page"));
            var companyId = Convert.ToInt32(GetParam("companyId"));
            var pageSize = GetPageSize();
            var page = _serviceUser.PagesByCompanyID(pageIndex, pageSize, companyId, model);
            ViewBag.Total = page.total;
            ViewBag.PageIndex = pageIndex;
            ViewBag.PageSize = pageSize;
            return PartialView(page.rows);
        }
    }
}